#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> distributeCandies(int candies, int num_people) {
        int now = 0;
        vector<int> v1;
        v1.resize(num_people);
        while (candies)
        {
            for (int i = 0; i < num_people; ++i)
            {
                if (candies - (now + 1) < 0)
                {
                    v1[i] += candies;
                    candies = 0;
                    break;
                }
                v1[i] += ++now;
                candies -= now;
            }
        }

        return v1;
    }
};